package com.yinhe.music.yhmusic.localmusic.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.Music;
import com.yinhe.music.yhmusic.widget.SmoothCheckBox;

import java.util.List;

/**
 * Created by hasee on 2017/8/15.
 */

public class LocalManagerAdapter extends BaseQuickAdapter<Music, BaseViewHolder> {

    public LocalManagerAdapter(@Nullable List<Music> data) {
        super(R.layout.select_item, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final Music item) {
        final SmoothCheckBox cb = helper.getView(R.id.scb);
        cb.setOnCheckedChangeListener((checkBox, isChecked) -> item.setChecked(isChecked));
        cb.setChecked(item.isChecked());

        helper.itemView.setOnClickListener((v) -> {
            item.setChecked(!item.isChecked());
            cb.setChecked(item.isChecked(), true);
        });

        helper.setText(R.id.tv, item.getSongName())
                .setGone(R.id.img,false);
    }
}
